<?php class Alumno { 

    /***
     * DB Fields: id_alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id_alumno;

    /***
     * DB Fields: id_persona
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id_persona;

    /***
     * DB Fields: escuela
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $escuela;

    /***
     * DB Fields: grado
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $grado;

    /***
     * DB Fields: promocion
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $promocion;

//--------------- GET METHODS ----------------------------- //
    /***
     * Get value for field: id_alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id_alumno
     **/
    function get_id_alumno( ) {
        // returns the value of id_alumno
        return $this->id_alumno;
    }


    /***
     * Get value for field: id_persona
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id_persona
     **/
    function get_id_persona( ) {
        // returns the value of id_persona
        return $this->id_persona;
    }


    /***
     * Get value for field: escuela
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result escuela
     **/
    function get_escuela( ) {
        // returns the value of escuela
        return $this->escuela;
    }


    /***
     * Get value for field: grado
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result grado
     **/
    function get_grado( ) {
        // returns the value of grado
        return $this->grado;
    }


    /***
     * Get value for field: promocion
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result promocion
     **/
    function get_promocion( ) {
        // returns the value of promocion
        return $this->promocion;
    }


//--------------- SET METHODS ----------------------------- //
    /***
     * Set value for field: id_alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id_alumno
     * @result void
     **/
    function set_id_alumno( $id_alumno ) {
        // sets the value of id_alumno
        $this->id_alumno = $id_alumno;
    }

    /***
     * Set value for field: id_persona
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id_persona
     * @result void
     **/
    function set_id_persona( $id_persona ) {
        // sets the value of id_persona
        $this->id_persona = $id_persona;
    }

    /***
     * Set value for field: escuela
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param escuela
     * @result void
     **/
    function set_escuela( $escuela ) {
        // sets the value of escuela
        $this->escuela = $escuela;
    }

    /***
     * Set value for field: grado
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param grado
     * @result void
     **/
    function set_grado( $grado ) {
        // sets the value of grado
        $this->grado = $grado;
    }

    /***
     * Set value for field: promocion
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param promocion
     * @result void
     **/
    function set_promocion( $promocion ) {
        // sets the value of promocion
        $this->promocion = $promocion;
    }

//--------------- CRUD METHODS ----------------------------- //
    /***
     * Create a new Record: alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id_alumno
     * @param id_persona
     * @param escuela
     * @param grado
     * @param promocion
     * @result void
     **/
    function createnew_alumno( $id_alumno, $id_persona, $escuela, $grado, $promocion ) {

        // items to be inserted in the database 
        $_obj = array($id_alumno,
                      $id_persona,
                      $escuela,
                      $grado,
                      $promocion); 

        // database object connection
        $dbConn = $GLOBALS['dbConn'];

        // perform insert in the database
        $dbConn->insert("alumno", $_obj);
    }

    /***
     * Retrived an existing record: alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id_alumno
     * @result new Alumno
     **/
    function get_alumno( $id_alumno ) {

        // retrive the data
        $dbConn = $GLOBALS['dbConn'];

        // retrieved value in the database
        $_resultSet = $dbConn->doQuery("SELECT * FROM alumno WHERE id_alumno = '$id_alumno'");

        $__alumnoObj = new alumno();
        // return the retrived from the database

        // create a new object
        $__obj = new Alumno();
        $__obj->set_id_alumno($_resultSet[0]['id_alumno']);
        $__obj->set_id_persona($_resultSet[0]['id_persona']);
        $__obj->set_escuela($_resultSet[0]['escuela']);
        $__obj->set_grado($_resultSet[0]['grado']);
        $__obj->set_promocion($_resultSet[0]['promocion']);


        return $__obj;
    }

    /***
     * Update an existing record: alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id_alumno
     * @param itemsToBeUpdated = array()
     * @result void
     **/
    function update_alumno( $id_alumno, $itemsToBeUpdated = array() ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs update in the database
         foreach($itemsToBeUpdated as $_fName => $_fVal) { 
               $dbConn->addValuePair($_fName, $_fVal);
         }

         // perform update operation
         $dbConn->update("alumno", "id_alumno = '$id_alumno'");
    }

    /***
     * Delete an existing record: alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id_alumno
     * @result void
     **/
    function delete_alumno( $id_alumno ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs deletion of data
         $dbConn->delete("alumno", "id_alumno = '$id_alumno'");
    }

    /***
     * Retrived list of objects base on a given parameters: alumno
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param conditionalStatement = ''
     * @result collection of objects: Alumno
     **/
    function list_alumno( $conditionalStatement = '' ) {

         $dbConn = $GLOBALS['dbConn'];
         // check if there is a given parameter list
         if(!empty($conditionalStatement)) { 
              $sqlStatement = "SELECT * FROM alumno WHERE $conditionalStatement"; 
         } else { 
              $sqlStatement = "SELECT * FROM alumno";
         }

         // retrieve the values base on the query result
         $__resObj = $dbConn->doQuery($sqlStatement);

         $__collectionOfObjects = array();
         foreach($__resObj as $__rs) { 
            $__newObj = new Alumno();

            $__newObj->set_id_alumno($__rs['id_alumno']);
            $__newObj->set_id_persona($__rs['id_persona']);
            $__newObj->set_escuela($__rs['escuela']);
            $__newObj->set_grado($__rs['grado']);
            $__newObj->set_promocion($__rs['promocion']);

            // add object to collection 
            array_push($__collectionOfObjects, $__newObj);
         }

         // return collection of objects
         return $__collectionOfObjects;
    }

} ?>